package com.example.demo05.securityHandler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
@Slf4j
public class CustomizeLogoutHandler implements LogoutHandler {
    @Override
    public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) {
        String header = httpServletRequest.getHeader("Authorization");
        log.info("logout Token,{}",header);
        log.info("logout request getMethod,{}",httpServletRequest.getMethod());
        SecurityContextHolder.clearContext();
    }

}
